<%@page language="java" contentType="application/json; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.*" import="cart.hibernate.releaseCompany.*, cart.hibernate.movieInformation.*" import="cart.*,java.net.*,java.text.*" %>
<%@page import="cart.hibernate.coverImage.*, cart.hibernate.rating.*, cart.hibernate.order.*, cart.hibernate.genre.*, cart.hibernate.actor.*" %> 
<jsp:useBean id="movieInformationManager" scope="request" class="cart.hibernate.movieInformation.ManageMovieInformation" />
<%
    int id = Integer.parseInt(request.getParameter("movieid"));
    double newRate = Double.parseDouble(request.getParameter("rate"))*2;

    List movieInformationList = movieInformationManager.getAllMovie();
    //List orderList = orderManager.getAllOrder();

    Iterator iterMovieInformation = movieInformationList.iterator();
    
    while (iterMovieInformation.hasNext())
    {

        MovieInformation movieInformation = (MovieInformation) iterMovieInformation.next();
        if((movieInformation.getMovieId() - id + 1) < 1)
                continue;
        movieInformationManager.updateMovieRating(id, newRate);
%>
{
"avg": "<%=movieInformation.getRating().getAvgRate()/2%>",
}
<%
        break;
    }
%>
